a = {'zero': 0,
     'one': 1,
     'two': 2,
     'three': 3,
     'four': 4,
     'five': 5,
     'six': 6,
     'seven': 7,
     'eight': 8,
     'nine': 9}
b = input()
n = ''
c = ''
m = b.split()

for i in b.split():
    if i not in a or m[0] == 'zero' or (len(b.split()) > 3 or len(b.split()) < 3):
        print('Wrong input')
        exit()
    else:
        c = a.get(str(i))
    n += str(c)

n = int(n)
s1 = n
s = n
ans = n
g = ''
k = 0

for i in range(2, n // 2 + 1):
    if n % i == 0:
        k = k + 1
if k <= 0:
    g = True
else:
    g = False
if g:
    print(n)
else:
    k = 0
    while not g:
        s1 += 1
        for i in range(2, s1 // 2 + 1):
            if s1 % i == 0:
                k = k + 1
        if k <= 0:
            g = True
            break
        else:
            g = False
        k = 0
    k = 0
    g = False
    while not g:
        s -= 1
        for i in range(2, s // 2 + 1):
            if s % i == 0:
                k = k + 1
        if k <= 0:
            g = True
            break
        else:
            g = False
        k = 0
    if ans - s1 < ans - s:
        print(s1)
    else:
        print(s)